package com.kkwrite.regimen.provider.controller.activity;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kkwrite.regimen.common.entity.dto.OutDTO;
import com.kkwrite.regimen.common.entity.dto.activity.ActivityApplyInDTO;
import com.kkwrite.regimen.common.entity.dto.activity.ActivityApplyOutDTO;
import com.kkwrite.regimen.common.entity.dto.activity.ActivityDTO;
import com.kkwrite.regimen.provider.service.avtivity.ActivityService;

/**
 *
 * @author jinying
 * 
 */
@RestController
@RequestMapping(value = "/activity")
public class ActivityController {

    @Resource(name = "activityService")
    private ActivityService activityService;

    @PostMapping(value = "/insertActivityApply/{userId}")
    public OutDTO insertActivityApply(@RequestBody ActivityApplyInDTO activityApplyInDTO,@PathVariable Long userId) {
    	ActivityApplyOutDTO  activityApplyOutDTO= activityService.insertActivityApply(activityApplyInDTO,userId);
    	return new OutDTO(activityApplyOutDTO.getSuccess(),activityApplyOutDTO.getMsg(),null,activityApplyOutDTO);
    }
    
    @GetMapping(value = "/queryActivity/{activityCode}")
    public OutDTO queryActivity(@PathVariable String activityCode,Long userId) {
    	OutDTO<ActivityDTO> outDto =new OutDTO<ActivityDTO>();
    	ActivityDTO activityDTO = activityService.queryActivity(activityCode,userId);
    	outDto.setData(activityDTO);
    	outDto.setSuccess(activityDTO.getSuccess());
    	outDto.setMsg(activityDTO.getMsg());
    	return outDto;
    }

}
